
<div class="bar bar-header bar-clear">
	<button class="button button-clear" onclick="window.history.go(-1)">
		<i class="icon ion-ios-arrow-back active"></i>
		<span class="active">返回</span>
	</button>
	<button class="button button-clear" id="save">
		<span class="active">保存</span>
	</button>
</div>

<div class="page">
	<div class="h44"></div>
	<div class="hd">
		<div class="weui_cells_title">手机号：</div>
		<div class="weui_cells weui_cells_form">
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input" name="mobile" value="{$user['mobile']}" type="tel" pattern="[0-9]*" placeholder="请输入您的电话号码">
                </div>
            </div>
        </div>
        
        <div class="weui_cells_title">姓名：</div>
		<div class="weui_cells weui_cells_form">
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input" name="realname" value="{$user['realname']}" type="text" placeholder="请输入您真实姓名">
                </div>
            </div>
        </div>
	</div>
</div>

<script>
require(['jquery','core'],function($,core){
	$('#save').click(function(){
		var mobile = $('input[name="mobile"]').val();
		var realname = $('input[name="realname"]').val();
		
		var reg = /^1[3|4|5|8][0-9]\d{4,8}$/;
		console.log(reg.test(mobile));
		if (!reg.test(mobile)) {
			core.cancel('手机号码格式有误！请重新输入');
			return '';
		}
		
		if(core.empty(realname)){
			core.cancel('请认真填写您的姓名');
			return '';
		}
		
		core.post('home_edit',{act:'post',mobile:mobile,realname:realname},function(){
			core.ok("数据保存成功",function(){
				$.pjax({
					url:"{php echo $this->createMobileUrl('home')}",
					container:"#pjax-container"
				});
			});
		});
	});
});
</script>